<?php
class BuyauthorizeController extends NodeController {
	
	public function sq() {
		$rs = self::getBuyAuthorize ()->vaild ( $this->_user_global, $_POST ['password'] );
		self::getLogService ()->add ( $this->_user_global ['real_name'], $rs [message] );
		$this->sendNotice ( $rs ['message'], null, $rs ['status'] );
	}
	
	public function pwd() {
		$this->view ()->display ( "file:buy/pwd.tpl" );
	}
	
	public function save() {
		$rs = self::getBuyAuthorize ()->save ( $this->_user_global, $_POST ['oldpwd'], $_POST ['newpwd'] );
		self::getLogService ()->add ( $this->_user_global ['real_name'], $rs [message] );
		
		$this->sendNotice ( $rs ['message'], null, $rs ['status'] );
	}
	
	public function init() {
		self::getLogService ()->add ( $this->_user_global ['real_name'], "初始化授权码" . $_GET ['uid'] );
		echo self::getBuyAuthorize ()->init ( $_GET ['uid'] );
	
	}
	
	public function add() {
		self::getLogService ()->add ( $this->_user_global ['real_name'], "增加授权" . $_GET ['uid'] );
		
		echo self::getBuyAuthorize ()->addUser ( $_GET ['uid'] );
	
	}
	
	public static function getBuyAuthorize() {
		return new BuyAuthorizeService ();
	}

}